Skip to main content

TridentRouter

The TridentRouter contract is used for facilitating swaps between pairs.

The full contract can be found here.

State-Changing Functions

exactInputSingle

function exactInputSingle(ExactInputSingleParams calldata params) public payable returns (uint256 amountOut);

Performs a swap from token A to token B in a single pool. The swap is performed on bento tokens.

  • params includes the address of token A, pool, amount of token A to swap, minimum amount of token B after the swap and data required by the pool for the swap.
  • Ensure that the pool is trusted before calling this function. The pool can steal users' tokens.

Parameters

NameTypeDescription
paramsExactInputSingleParamsThe parameters for the swap

Returns

NameTypeDescription
amountOutuint256The amount of token B received

exactInput

function exactInput(ExactInputParams calldata params) public payable returns (uint256 amountOut);

Performs a swap from token A to token B across multiple hops.

  • params includes the addresses of the tokens, pools, amount of token A to swap, minimum amount of token B after the swap and data required by the pools for the swaps.
  • Ensure that the pools are trusted before calling this function. The pools can steal users' tokens.

Parameters

NameTypeDescription
paramsExactInputParamsThe parameters for the swaps

Returns

NameTypeDescription
amountOutuint256The final amount of token B received

exactInputSingleWithNativeToken

function exactInputSingleWithNativeToken(ExactInputSingleParams calldata params) public payable returns (uint256 amountOut);

Performs a swap from token A to token B in a single pool. The swap is performed on native ERC-20 tokens, which are deposited into bento before the swap.

  • params includes the address of token A, pool, amount of token A to swap, minimum amount of token B after the swap and data required by the pool for the swap.
  • Ensure that the pool is trusted before calling this function. The pool can steal users' tokens.

Parameters

NameTypeDescription
paramsExactInputSingleParamsThe parameters for the swap

Returns

NameTypeDescription
amountOutuint256The amount of token B received

exactInputWithNativeToken

function exactInputWithNativeToken(ExactInputParams calldata params) public payable returns (uint256 amountOut);

Performs a swap from token A to token B across multiple hops. The swap is performed on native ERC-20 tokens, which are deposited into bento before the swap.

  • params includes the addresses of the tokens, pools, amount of token A to swap, minimum amount of token B after the swap and data required by the pools for the swaps.
  • Ensure that the pools are trusted before calling this function. The pools can steal users' tokens.

Parameters

NameTypeDescription
paramsExactInputParamsThe parameters for the swaps

Returns

NameTypeDescription
amountOutuint256The final amount of token B received

complexPath

function complexPath(ComplexPathParams calldata params) public payable;

Performs a complex swap operation from multiple input tokens to multiple output tokens using different paths and proportions. For example, you can swap 50 DAI + 100 USDC into 60% ETH and 40% BTC.

  • params includes everything needed for the swap. Look at the ComplexPathParams struct for more details.
  • This function is not optimized for single swaps and should only be used in complex cases where the amounts are large enough that minimizing slippage by using multiple paths is worth the extra gas.

Parameters

NameTypeDescription
paramsComplexPathParamsThe parameters for the swap

addLiquidity

function addLiquidity(TokenInput[] calldata tokenInput, address pool, uint256 minLiquidity, bytes calldata data) public payable returns (uint256 liquidity);

Adds liquidity to a specified pool.

  • tokenInput specifies the tokens and the corresponding amounts to be deposited as liquidity.
  • pool is the address of the pool to which liquidity will be added.
  • minLiquidity is the minimum amount of liquidity tokens the caller is willing to receive. This parameter sets a limit on slippage.
  • data is additional data that might be required by the pool to add liquidity.

Parameters

NameTypeDescription
tokenInputTokenInput[]Tokens and corresponding amounts to add as liquidity
pooladdressAddress of the pool to add liquidity to
minLiquidityuint256Minimum liquidity the caller is willing to receive
databytesAdditional data required by the pool to add liquidity

Returns

NameTypeDescription
liquidityuint256Amount of liquidity tokens minted

burnLiquidity

function burnLiquidity(address pool, uint256 liquidity, bytes calldata data, IPool.TokenAmount[] calldata minWithdrawals) public payable;

Burns liquidity tokens to withdraw tokens from a specified pool.

  • pool is the address of the pool from which tokens will be withdrawn.
  • liquidity is the amount of liquidity tokens to be burnt.
  • data is additional data that might be required by the pool to burn liquidity.
  • minWithdrawals is the minimum amount of each token that the caller is willing to receive. This parameter sets a limit on slippage.

Parameters

NameTypeDescription
pooladdressAddress of the pool to burn liquidity from
liquidityuint256Amount of liquidity tokens to burn
databytesAdditional data required by the pool to burn liquidity
minWithdrawalsIPool.TokenAmount[]Minimum amount of each token the caller is willing to receive

burnLiquiditySingle

function burnLiquiditySingle(address pool, uint256 liquidity, bytes calldata data, uint256 minWithdrawal) public payable;

Burns liquidity tokens to withdraw a single type of token from a specified pool.

  • pool is the address of the pool from which tokens will be withdrawn.
  • liquidity is the amount of liquidity tokens to be burnt.
  • data is additional data that might be required by the pool to burn liquidity.
  • minWithdrawal is the minimum amount of tokens that the caller is willing to receive. This parameter sets a limit on slippage.

Parameters

NameTypeDescription
pooladdressAddress of the pool to burn liquidity from
liquidityuint256Amount of liquidity tokens to burn
databytesAdditional data required by the pool to burn liquidity
minWithdrawaluint256Minimum amount of tokens the caller is willing to receive

sweep

function sweep(address token, address recipient, bool fromBento) external payable;

Recovers mistakenly sent tokens.

  • token is the address of the token to be recovered.
  • recipient is the address that will receive the recovered tokens.
  • fromBento is a boolean indicating if the tokens to be swept are from the BentoBox contract.

Parameters

NameTypeDescription
tokenaddressAddress of the token to be recovered
recipientaddressAddress that will receive the recovered tokens
fromBentoboolIndicates if the tokens to be swept are from the BentoBox contract

unwrapWETH

function unwrapWETH(address recipient) external payable;

Unwraps the contract's wETH into ETH.

  • recipient is the address that will receive the unwrapped ETH.

Parameters

NameTypeDescription
recipientaddressAddress that will receive the unwrapped ETH

deployPool

function deployPool(address factory, bytes calldata deployData) external payable returns (address);

Deploys a new pool.

  • factory is the address of the factory contract that will create the pool.
  • deployData is the data needed to deploy the pool.

Parameters

NameTypeDescription
factoryaddressAddress of the factory contract that will create the pool
deployDatabytesData needed to deploy the pool

Returns

NameTypeDescription
(unnamed)addressAddress of the deployed pool

approveMasterContract

function approveMasterContract(uint8 v, bytes32 r, bytes32 s) external payable;

Approves a master contract in the BentoBox contract.

  • v, r, s are the v, r, s components of a signature.

Parameters

NameTypeDescription
vuint8v component of a signature
rbytes32r component of a signature
sbytes32s component of a signature

harvest

function harvest(address token, uint256 maxChangeAmount) external payable;

Calls the BentoBox harvest function to rebalance a BentoBox token strategy and ensure there are enough tokens available to withdraw a swap output.

  • token is the address of the token to be harvested.
  • maxChangeAmount is the maximum amount by which the balance of the token can change during the harvest operation.

Parameters

NameTypeDescription
tokenaddressAddress of the token to be harvested
maxChangeAmountuint256Maximum amount by which the balance of the token can change during the harvest operation